<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Use correct character set. -->
    <meta charset="utf-8">
    <!-- Tell IE to use the latest, best version. -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Make the application on mobile take up the full browser screen and disable user scaling. -->
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
    <title>Hello World!</title>
    <script src="js/Cesium.js"></script>
    <script src="js/require.js"></script>
    <script src="js/Sandcastle-header.js"></script>
    <script src="js/jquery-3.4.1.min.js"></script>
    <style>
        @import url(css/widgets.css);

        html, body, #cesiumContainer {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            overflow: hidden;
        }
    </style>

</head>
<div id="credit"></div>
<body>
<div id="cesiumContainer" class="fullSize"></div>
<div id="toolbar"></div>

<script>

    var data = [
        1,116.59,39.88,10000,
        2,116.83,39.84,20000,
        3,117.06,39.79,30000,
        4,117.30,39.75,40000,
        5,117.53,39.71,50000,
        6,117.76,39.67,60000,
        7,118.00,39.62,70000,
        8,118.23,39.58,80000,
        9,118.47,39.54,90000,
        10,118.70,39.50,100000,
        11,118.93,39.45,110000,
        12,119.17,39.41,120000,
        13,119.40,39.37,130000,
        14,119.63,39.33,140000,
        15,119.87,39.28,150000,
        16,120.10,39.24,160000,
        17,120.34,39.20,170000,
        18,120.57,39.16,180000,
        19,120.80,39.11,190000,
        20,121.04,39.07,200000,
        21,121.27,39.03,210000,
        22,121.51,38.99,220000,
        23,121.74,38.94,230000,
        24,121.97,38.90,240000,
        25,122.21,38.86,250000,
        26,122.44,38.82,260000,
        27,122.68,38.78,270000,
        28,122.91,38.73,280000,
        29,123.14,38.69,290000,
        30,123.38,38.65,300000,
        31,123.61,38.61,310000,
        32,123.84,38.56,320000,
        33,124.08,38.52,330000,
        34,124.31,38.48,340000,
        35,124.55,38.44,350000,
        36,124.78,38.39,360000,
        37,125.01,38.35,370000,
        38,125.25,38.31,380000,
        39,125.48,38.27,390000,
        40,125.72,38.22,400000,
        41,125.95,38.18,410000,
        42,126.18,38.14,420000,
        43,126.42,38.10,430000,
        44,126.65,38.05,440000,
        45,126.89,38.01,450000,
        46,127.12,37.97,460000,
        47,127.35,37.93,470000,
        48,127.59,37.88,480000,
        49,127.82,37.84,490000,
        50,128.06,37.80,500000,
        51,128.29,37.76,490000,
        52,128.52,37.72,480000,
        53,128.76,37.67,470000,
        54,128.99,37.63,460000,
        55,129.22,37.59,450000,
        56,129.46,37.55,440000,
        57,129.69,37.50,430000,
        58,129.93,37.46,420000,
        59,130.16,37.42,410000,
        60,130.39,37.38,400000,
        61,130.63,37.33,390000,
        62,130.86,37.29,380000,
        63,131.10,37.25,370000,
        64,131.33,37.21,360000,
        65,131.56,37.16,350000,
        66,131.80,37.12,340000,
        67,132.03,37.08,330000,
        68,132.27,37.04,320000,
        69,132.50,36.99,310000,
        70,132.73,36.95,300000,
        71,132.97,36.91,290000,
        72,133.20,36.87,280000,
        73,133.43,36.82,270000,
        74,133.67,36.78,260000,
        75,133.90,36.74,250000,
        76,134.14,36.70,240000,
        77,134.37,36.66,230000,
        78,134.60,36.61,220000,
        79,134.84,36.57,210000,
        80,135.07,36.53,200000,
        81,135.31,36.49,190000,
        82,135.54,36.44,180000,
        83,135.77,36.40,170000,
        84,136.01,36.36,160000,
        85,136.24,36.32,150000,
        86,136.48,36.27,140000,
        87,136.71,36.23,130000,
        88,136.94,36.19,120000,
        89,137.18,36.15,110000,
        90,137.41,36.10,100000,
        91,137.64,36.06,90000,
        92,137.88,36.02,80000,
        93,138.11,35.98,70000,
        94,138.35,35.93,60000,
        95,138.58,35.89,50000,
        96,138.81,35.85,40000,
        97,139.05,35.81,30000,
        98,139.28,35.76,20000,
        99,139.52,35.72,10000,
        100,139.75,35.68,0
    ];

    var czml = [{
        "id": "document",
        "name": "Demo",
        "version": "1.0",
        "clock": {
            "interval": "2012-08-04T10:00:00Z/2012-08-04T10:01:45Z",
            //当前时间
            "currentTime": "2012-08-04T10:00:00Z",
            "multiplier": 5
        }
    }, {
        "id": "path",
        "name": "path with GPS flight data",
        "description": "<p>Hang gliding flight log data from Daniel H. Friedman.<br>Icon created by Larisa Skosyrska from the Noun Project</p>",
        "availability": "2012-08-04T10:00:00Z/2012-08-04T10:01:45Z",
        "path": {
            "material": {
                "polylineOutline": {
                    "color": {
                        "rgba": [0, 0, 0, 0]
                    },
                    "outlineColor": {
                        "rgba": [0, 0, 0, 0]
                    },
                    "outlineWidth": 5
                }
            },
            "width": 8,
            "leadTime": 10,
            "trailTime": 1000,
            "resolution": 5
        },
        "position": {
            "epoch": "2012-08-04T10:00:00Z",
            "cartographicDegrees": data
        },
        "model": {
            "gltf": "model/model.gltf",
            "scale": 1.0,
            "minimumPixelSize": 1
        },
        "distanceDisplayCondition ": [
            0, 150, 15000000,
            300, 10000, 15000000,
            600, 150, 15000000
        ],
        "orientation": {
            "interpolationAlgorithm": "LINEAR",
            "interpolationDegree": 1,
            "epoch": "2012-08-04T10:00:00Z",
            "unitQuaternion": [
                0, 30.0, 50.0, 0.0, 50.0,
                50, 20.0, 10.0, 30.0, 0.0,
                100, 0.0, 15.0, 30.0, 0.0
            ]
        }
    }, {}];

    function startup(Cesium, flag) {


        var viewer = new Cesium.Viewer('cesiumContainer', {
            shouldAnimate: flag,
            // infoBox: false,
            // selectionIndicator: false,
            shadows: false,
            geocoder: false,
            homeButton: false,
            sceneModePicker: false,
            baseLayerPicker: false,
            navigationHelpButton: false,
            animation: false,
            timeline: false,
            fullscreenButton: false
        });


        var dataSourcePromise = viewer.dataSources.add(Cesium.CzmlDataSource.load(czml));

        dataSourcePromise.then(function (dataSource) {
            viewer._cesiumWidget._creditContainer.style.display = "none";
            viewer.trackedEntity = dataSource.entities.getById('path');

        }).otherwise(function (error, dataSource) {
            viewer.flyTo(dataSource);
            window.alert(error);
        });
    }

    if (typeof Cesium !== 'undefined') {

        var random = Math.floor(Math.random() * 100) + 1;

        // console.log("随机数：" + random)
        if (random < 70){
        startup(Cesium, true);
        console.log("发射成功！")
        }else{
            startup(Cesium,false);
            console.log("发射失败！")
        }

    } else if (typeof require === 'function') {
        require(['Cesium'], startup);
    }
</script>

</body>
</html>